function cekNama(name)
{
	var patt = /^[A-Za-z\s]{5,}$/;		//char yang boleh abjad spasi dan min length
	if(patt.test(name))
	{
	    document.getElementById("CekNama").innerHTML = "";   //set error mark
		return true;}
	else
	{
	    document.getElementById("CekNama").innerHTML = "(!!!)";   //set error mark
		alert("Name Not Valid");
		return false;
	}	
}

function cekUser(user)
{
    var patt = /^[A-z._\d]{5,}$/;
	var patt2 = /\s/ ;
	if(patt.test(user))
	{
		if(!patt2.test(user))
	  document.getElementById("CekUserName").innerHTML = "";   //set error mark
			return true;
	}
	else
	{
	  document.getElementById("CekUserName").innerHTML = "(!!!)";   //set error mark
		alert("User Not Valid");	return false;
	}
}

function cekPswd(pwd)
{
    var patt = /^.{6,}$/;
	if(patt.test(pwd))
	{
        document.getElementById("CekPassword").innerHTML = "";   //set error mark
		return true;}
	else
	{
        document.getElementById("CekPassword").innerHTML = "(!!!)";   //set error mark
		alert("Password Not Valid");
		return false;
	}
}

function ConfirmPswd(pwd,cpwd)
{
	if(cekPswd(pwd))
	{
		if(pwd == cpwd)
		{
		  document.getElementById("CekConfirm").innerHTML = "";   //set error mark
			return true;
		}
		else
		{
		  document.getElementById("CekConfirm").innerHTML = "(!!!)";   //set error mark
            alert("Confirm Password Not Valid");
			return false;
		}
	}
}


function cekTglLahir(bdate)
{
	var patt=/^\d{4}[-]([0](?:[0-9])|[1](?:[012]))[-]([012](?:[0-9])|[3](?:[01]))$/
	if(patt.test(bdate))
	{
	  document.getElementById("CekBirth").innerHTML = "";   //set error mark
		return true;}
	else
	{
	  document.getElementById("CekBirth").innerHTML = "(!!!)";   //set error mark
		alert("Birthdate Not Valid");
		return false;
	}	

}

function cekEmail(email)
{
	var patt=/^[A-Za-z0-9._]{5,}@.+[.]\w{2,}$/
	if(patt.test(email))
	{
	  document.getElementById("CekEMail").innerHTML = "";   //set error mark
		return true;}
	else
	{
	  document.getElementById("CekEMail").innerHTML = "(!!!)";   //set error mark
		alert("Email Not Valid");
		return false;
	}	
}

function cekFoto(ppic)
{
	var patt=/^.+(?:.jpg)$|.+(?:.bmp)$|.+(?:.jpeg)$|.+(?:.png)$/
	if(patt.test(ppic))
	{
	  document.getElementById("CekPicture").innerHTML = "";   //set error mark
		return true;}
	else
	{
	  document.getElementById("CekPicture").innerHTML = "(!!!)";   //set error mark
		alert("File Type Not Valid");
		return false;
	}	
}

function cekLokasi(lokasi)
{
	var patt=/^.{5,}$/
	if(patt.test(lokasi))
	{
	  document.getElementById("CekLokasi").innerHTML = "";   //set error mark
		return true;}
	else
	{
	  document.getElementById("CekLokasi").innerHTML = "(!!!)";   //set error mark
		alert("Location Not Valid");
		return false;
	}	
	
}


function cekAll()
{
    var name = (document.getElementById('nama')).value   ;
    var user = (document.getElementById('user')).value   ;
    var pswd = (document.getElementById('pswd')).value   ;
    var cpswd = (document.getElementById('cpswd')).value   ;
	var bdate = (document.getElementById('bdate')).value   ;
	var email = (document.getElementById('email')).value   ;
	var ppic = (document.getElementById('ppic')).value   ;
	var lokasi = (document.getElementById('lokasi')).value   ;
//alert(pswd +"+"+cpswd);
	var a = cekNama(name);
	var b = cekUser(user);
	var c = cekPswd(pswd);
	var d = ConfirmPswd(pswd,cpswd);
	var e = cekTglLahir(bdate);
	var f = cekEmail(email);
	var g = cekFoto(ppic);
	var h = cekLokasi(lokasi);
	
	if(a && b && c && d && e && f && g && h)
		alert("Submitted");
	else
		alert("Not Submitted");
	
}